<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>js函数</title>
		<script>
		  document.write("<h1>计算加法</h1>");
		  var c=1;
		   function add(a,b="ok"){
			   var res= a+b;
			   document.write(res);
		   }
		   //var c=add(10,3);
		   //alert(c);
		   function sayhello(n=10){
			   for(var i=1;i<=n;i++){
				   document.write("<h1>"+i+"中午好</h1>");
				   //document.close();
			   }
		   }
		</script>
	</head>
	<body>
		<div id="d1" style="height: 300px;background-color: blue;" ondblclick="alert('你双击了')">
			
		</div>
		<input type="button" value="点击" onclick="add(12,5)" />
		<input type="button" value="问好" onclick="sayhello()"/>
		<input type="button" value="问好2" onclick="sayhello(prompt('input a number:'))"/>
	</body>
</html>
